home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / communication / internet / amitcp3.0b / src.lha / src / l / inet-handler / runstart.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-08  |  1.8 KB  |  85 lines

  1. /*
  2.  * runstart.c
  3.  *
  4.  * crabbed and modified from Matt Dillon's fifo-handler
  5.  *
  6.  * Last modified: Fri Oct  8 19:32:19 1993 too
  7.  *
  8.  * HISTORY
  9.  * $Log: runstart.c,v $
  10.  * Revision 1.1  1993/10/24  12:50:39  too
  11.  * Initial revision
  12.  *
  13.  *
  14.  */
  15.  
  16. #include <exec/types.h>
  17. #include <exec/nodes.h>
  18. #include <exec/ports.h>
  19. #include <exec/memory.h>
  20. #include <dos/dos.h>
  21. #include <dos/dosextens.h>
  22.  
  23. #define _INL_SOCKET_H_ /* socket functions aren't needed here */
  24. #define PROTO_SOCKET_H
  25. #include "system_includes.h"
  26.  
  27. #include "runstart.h"
  28.  
  29. static struct DosList * dl; /* well, this is for testing only */
  30.  
  31. extern struct DosLibrary * DOSBase;
  32.  
  33. struct MsgPort * mkDevice(char * devname, int namelen)
  34. {
  35.   struct RootNode *    root;
  36.   struct DosInfo *    info;
  37.   struct MsgPort *    PktPort;
  38.   
  39.   if ((PktPort = CreateMsgPort()) == NULL)
  40.     return NULL;
  41.   
  42.   dl = (struct DosList *)
  43.     AllocMem(sizeof(struct DosList) + namelen + 2, MEMF_PUBLIC);
  44.   if (dl == NULL) {
  45.     DeleteMsgPort(PktPort);
  46.     return NULL;
  47.   }
  48.   CopyMem(devname, (char *)(dl + 1) + 1, namelen);
  49.   *(char *)(dl + 1) = namelen;
  50.   
  51.   dl->dol_Type = DLT_DEVICE;
  52.   dl->dol_Task = PktPort;
  53.   dl->dol_Name = MKBADDR((char *)(dl+1));
  54.   
  55.   Forbid();
  56.   root  = (struct RootNode *)DOSBase->dl_Root;
  57.   info  = (struct DosInfo  *)BADDR(root->rn_Info);
  58.   dl->dol_Next = info->di_DevInfo;
  59.   info->di_DevInfo = MKBADDR(dl);
  60.   Permit();
  61.   
  62.   return PktPort;
  63. }
  64.  
  65. void delDevice()
  66. {
  67.   struct DosInfo *    info;
  68.   struct RootNode *    root;
  69.   struct DosList *    dls;
  70.   BPTR *        bpp;
  71.   
  72.   Forbid();
  73.   root  = (struct RootNode *)DOSBase->dl_Root;
  74.   info  = (struct DosInfo  *)BADDR(root->rn_Info);
  75.   
  76.   for (bpp = &info->di_DevInfo; (dls = BADDR(*bpp)); bpp = &dls->dol_Next)
  77.     if (dls == dl) {
  78.       *bpp = dls->dol_Next;
  79.       DeleteMsgPort(dl->dol_Task);
  80.       FreeMem(dl, sizeof(struct DosList) +
  81.           (int)*(char *)BADDR(dl->dol_Name) + 2);
  82.     }
  83.   Permit();
  84. }
  85.